package com.dz.risk.controller;

import com.dz.risk.common.ResponseVO;
import com.dz.risk.common.exception.RRException;
import com.dz.risk.pojo.QueryParams;
import com.dz.risk.service.PressureTestIndexValueService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.text.ParseException;

/**
 * 债卷模块-压测指标值
 *
 * @author yinpl
 * @email
 * @date 2021-07-06 17:19:33
 */
@RestController
@RequestMapping("dz-ftsp/stest/pressureTestIndexValue")
@Api(tags = "压测指标值api", value = "压测指标值接口")
public class PressureTestIndexValueController {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
    @Autowired
    private PressureTestIndexValueService pressureTestIndexValueService;

    /**
     * 计算压测指标值
     */
    @ApiOperation("计算压测指标值")
    @PostMapping(value = "/numberation")
    public ResponseVO numberation(@RequestParam("formula") String formula, HttpServletRequest request){
        BigDecimal numberation = new BigDecimal("0");
        try {
            try {
              numberation = pressureTestIndexValueService.numberation(formula,request);
            } catch (Exception e) {
                e.printStackTrace();
                logger.error("计算失败！：" + e);
                return new ResponseVO(201,e.getMessage());
            }
        } catch (RRException e) {
            e.printStackTrace();
            logger.error("计算失败！：" + e);
            return new ResponseVO(e.getCode(),e.getMessage());
        }


        return new ResponseVO(200,String.valueOf(numberation));
    }
}
